//
// Created by Ivor_ on 2023/2/8.
//

#ifndef PHYSICAL_COMPUTING_PACKAGE_LOGISTICLIKE_H
#define PHYSICAL_COMPUTING_PACKAGE_LOGISTICLIKE_H

#include "../plotInFiles/plotBMP.h"

/**
 * @remark The variables and function with "static" is only used in this file for auxiliary.
 */

/**
 * @author Ivor
 * @param iterDim How many independent variables in iteration.
 * @param iterVar Independent variables.
 * @param argCount How many arguments in iteration.
 * @param args Arguments.
 * @return After once iteration, the iteration variables' value.
 * @remark Just for an example.
 */
double* logistic(int iterDim, double* iterVar, int argCount, double* args);

/**
 * @author Ivor
 * @param partialVarIndex Which dimention do you want to derivative.
 * @param iterDim How many independent variables in iteration, for iteration function.
 * @param iterVar Independent variables, for iteration function.
 * @param argCount How many arguments in iteration, for iteration function.
 * @param args Arguments, for iteration function.
 * @return After once iteration, the iterative variables' derivative value.
 * @remark Just for an example.
 */
double* partialDerivativeLogistic(int partialVarIndex, int iterDim, double* iterVar, int argCount, double* args);

/**
 * @author Ivor
 * @param fileName Output BMP file name, suffix .bmp will be auto add.
 * @param plotDim Which dimention do you want to plot, no more than iterDim.
 * @param plotIterMinIndex Just as its name, for the picture horizontal minimum value.
 * @param plotIterMaxIndex Just as its name, for the picture horizontal maximum value.
 * @param yMin Less than all the plot points, for vertical control the picture.
 * @param yMax Greater than all the plot points, for vertical control the picture.
 * @param iterFun For example, the function "logistic".
 * @param iterDim How many independent variables in iteration, for iteration function.
 * @param iterVar Independent variables, for iteration function.
 * @param argCount How many arguments in iteration, for iteration function.
 * @param args Arguments, for iteration function.
 * @remark Plot the scatter polyline to show the change in each iteration step.
 */
void plotIterChanges(char* fileName, int plotDim, int plotIterMinIndex, int plotIterMaxIndex, double yMin, double yMax, double*(*iterFun)(), int iterDim, double* iterVar, int argCount, double* args);
/**
 * @author Ivor
 * @param fileName Output BMP file name, suffix .bmp will be auto add.
 * @param plotDim Which dimention do you want to plot, no more than iterDim.
 * @param objArgIndex Which argument do you want to research.
 * @param objArgMin To ergodic the objective argument, the start point.
 * @param objArgMax To ergodic the objective argument, the end point, and must greater than objArgMin.
 * @param yMin Less than all the plot points, for vertical control the picture.
 * @param yMax Greater than all the plot points, for vertical control the picture.
 * @param iterN1 Ensure that after N1 times iteration, the state get into stable with constant period, N1 is greater greater than zero.
 * @param iterN2 Ensure that after (N2 - N1) is greater than any period, in this range, dots will be draw into the picture.
 * @param iterFun For example, the function "logistic".
 * @param iterDim How many independent variables in iteration, for iteration function.
 * @param iterVar Independent variables, for iteration function.
 * @param argCount How many arguments in iteration, for iteration function.
 * @param args Arguments, for iteration function.
 * @return Feigenbaum delta value, approach to 4.6692016661, while iterN2 approch to infinity.
 * @remark Show the Feigenbaum graph to analysis bifurcation changes with argument.
 */
double feigenbaum(char* fileName, int plotDim, int objArgIndex, double objArgMin, double objArgMax, double yMin, double yMax, int iterN1, int iterN2, double*(*iterFun)(), int iterDim, double* iterVar, int argCount, double* args);

/**
 * @author Ivor
 * @param fileName Output BMP file name, suffix .bmp will be auto add.
 * @param plotDim Which dimention do you want to plot, no more than iterDim.
 * @param objArgIndex Which argument is related.
 * @param objArgMin To ergodic the objective argument, the start point.
 * @param objArgMax To ergodic the objective argument, the end point, and must greater than objArgMin.
 * @param yMin Less than all the plot points and zero, for vertical control the picture.
 * @param yMax Greater than all the plot points and zero, for vertical control the picture.
 * @param iterNum To get average value.
 * @param iterFun For example, the function "logistic".
 * @param iterDerFun or example, the function "partialDerivativeLogistic".
 * @param partialIndex Which variable to be derivative, for itervation partial derivative function.
 * @param iterDim How many independent variables in iteration, for iteration (partial derivative) function.
 * @param iterVar Independent variables, for iteration (partial derivative) function.
 * @param argCount How many arguments in iteration, for iteration (partial derivative) function.
 * @param args Arguments, for iteration (partial derivative) function.
 * @remark Show the Lyapunov graph to analysis bifurcation chaos phenomenon with argument.
 */
void lyapunov(char* fileName, int plotDim, int objArgIndex, double objArgMin, double objArgMax, double yMin, double yMax, int iterNum, double*(*iterFun)(), double*(*iterDerFun)(), int partialIndex, int iterDim, double* iterVar, int argCount, double* args);

#endif //PHYSICAL_COMPUTING_PACKAGE_LOGISTICLIKE_H
